﻿@{
    ViewBag.Title = "我的试卷";
    Layout = "~/Views/Shared/_GridCommonLayout.cshtml";
}
<input type="hidden" id="courseId" value="@ViewBag.CourseID"/>
<input type="hidden" id="teaId" value="@ViewBag.TeaID"/>
<section id="widget-grid" class="">
    <div class="row">




        <!--Operation-->
        <div class="heading-buttons">


            <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                <h1 class="page-title txt-color-blueDark"><i class="fa fa-desktop fa-fw "></i>
                    我的试卷			
                </h1>
            </div>
            <div style="clear: both;">
            </div>
        </div>
        <!--/Operation-->


                <!--Search-->
            <form id="formSearch">
                <div>
                <input type="hidden" id="CourseId" name="CourseId" value="@ViewBag.CourseID"/>
                </div>
            </form>
        <!--/search-->


        <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12 sortable-grid ui-sortable">
            <div id="wid-id-0" class="jarviswidget jarviswidget-color-darken jarviswidget-sortable" data-widget-editbutton="false">
                <header>
                    <span class="widget-icon"><i class="fa fa-table"></i></span>
                    <h2>已考试卷</h2>
                </header>
                <div style="margin-top: 35px;">
                    <div class="jarviswidget-editbox"></div>
                    <div class="widget-body no-padding">
                        <div role="grid" id="providerGrid" class="dataTables_wrapper form-inline">
                            <div class="table-responsive">

                                <div class="dt-wrapper" style="overflow-y: auto;">
                                    <table class="table table-striped table-bordered table-hover checkboxs">
                                        <!--table head-->
                                        <thead>
                                            <tr>

                                                <!-- ko foreach: headers -->
                                                <th class="center ">
                                                    <a href="#" data-bind="text: displayText@*, click: $root.sort*@" style="color: black"></a>
                                                    <i class="icon-circle-arrow-up" data-bind="    visible: value == $root.orderBy() && $root.isAsc()"></i>
                                                    <i class="icon-circle-arrow-down" data-bind="    visible: value == $root.orderBy() && !$root.isAsc()"></i>
                                                </th>
                                                <!-- /ko -->
                                                <th class="center" style="width: 60px">查看
                                                </th>
                                            </tr>
                                        </thead>
                                        <!--/table head-->
                                        <!--table body(Provider list)-->
                                        <tbody data-bind="foreach: recordSet">
                                            <tr class="selectable" onclick="">


                                                <input type="hidden" data-bind="value: Id, attr: { id: Id }" />
                                                <input type="hidden" data-bind="value: IPaperId" />


                                                <td class='center'><strong data-bind='text: STestName'></strong></td>
                                                <td class='center'><strong data-bind='text: SStuCode'></strong></td>
                                                <td class='center'><strong data-bind='text: SStuName'></strong></td>
                                                <td class='center'><strong data-bind='text: SClassName'></strong></td>
                                                <td class='center'><strong data-bind='text: IScore'></strong></td>
                                                <td class='center'><strong data-bind='text: stateShow(IIsRead)'></strong></td>


                                                <td class="center">
                                                    <a href="#" class="btn-action glyphicons pencil btn-success" data-bind="click: $root.readPaper">
                                                        <i></i></a>
                                                </td>
                                            </tr>
                                        </tbody>
                                        <!--/table body( Provider list)-->

                                    </table>

                                </div>



                                <!-- 分页 -->
                                <ul class="pagination pagination-alt">
                                    <li>
                                        <a data-bind="click: firstPage"><i class="fa fa-fast-backward "></i></a>
                                    </li>
                                    <li>
                                        <a data-bind="click: prevPage"><i class="fa  fa-backward  "></i></a>
                                    </li>
                                    <li>
                                        <a>
                                            <input id="toPage" type="text" data-bind="value: pageIndex, event: { change: $root.changePageIndex }" style="width: 25px;" />
                                            /共<span data-bind="html: totalPages"></span>页 
                                        </a>
                                    </li>
                                    <li>
                                        <a data-bind="click: nextPage"><i class="fa fa-forward "></i></a>
                                    </li>
                                    <li>
                                        <a data-bind="click: lastPage"><i class="fa fa-fast-forward "></i></a>
                                    </li>
                                </ul>

                                <div class="dt-top-row total  ">
                                    当前记录共：<span data-bind="html: totalCount"></span>条
                                </div>
                                <!--end 分页-->
                            </div>

                            <!-- /分页 -->


                        </div>

                        <!-- /分页 -->




                    </div>
                </div>

            </div>




        </article>

    </div>
    <!--end row-->
</section>


<script type="text/javascript">

    //状态显示
    function stateShow(i) {
        if (i == 0)
            return "未阅";
        else
            return "已阅";
    }

    var gdViewModel;
    $(function () {

        $._messengerDefaults = {
            extraClasses: 'messenger-fixed messenger-theme-future messenger-on-bottom messenger-on-right'
        }; //默认提示位置;


        var options = {

            dialogId: "TestScoresMessageModal", //添加对话框

            pageSize: 20, //分页大小
            hidId: $("#txtbID"),
            SaveUpdateBtn: $("#btnSaveOrUpdateModel"),
            frmElement: $("#formTestScores"),
            DefultGet:"POST",

            //节点数据
            NodeValue: ko.observable({

                Id: 0,
                STestName: '',
                ICourseId: 0,
                SCouseCode: '',
                ITeaId: 0,
                STeaCode: '',
                ITermId: 0,
                ITestType: 0,
                IStuId: 0,
                SStuCode: '',
                IScore: 0,
                IPaperId: 0,
                IIsRead: 0,


            }),


            //用户列表Grid头部列名称
            headers: [



 { displayText: '试卷名', value: 'STestName', width: 'auto' },
 { displayText: '学号', value: 'SStuCode', width: 'auto' },
 { displayText: '姓名', value: 'SStuName', width: 'auto' },
 { displayText: '班级', value: 'SClassCode', width: 'auto' },
 { displayText: '得分', value: 'IScore', width: 'auto' },
 { displayText: '状态', value: 'IIsRead', width: 'auto' }

            ],

            //默认的排序方式
            defaultOrderBy: "Id",
            //用户查询URL
            dataQueryUrlAccessor: function () {
                return "/api/Student/GetByPaper";
            },

            //添加用户URL
            dataAddUrlAccessor: function () { },
            dataUpdateAccessor: function (key) { },
            dataNodeSelect: function (id) {
                return "/api/TestScores/get/" + id;
            },

            dataDeleteAccessor: function (data) {
                var userIDs = "";
                var check = $("input:checked");  //得到所有被选中的checkbox
                check.each(function (i) {        //循环拼装被选中项的值
                    userIDs = userIDs + ',' + $(this).val();
                });
                //清除多余的分割号
                userIDs = dropRsplit(userIDs, ",");
                if (userIDs != "") {
                    return appendQueryString("/api/TestScores/Delete", { ids: userIDs });
                } else
                    return "";

            }
			, initEd: function () {
			    //gird初始化的后置事件 信息

			}
            , changeEnd: function () {
                //对话框关闭后 的后置事件
            }
            , showDetailEnd: function (data) {

            }

        };

        gdViewModel = new gridViewModel(options);

        gdViewModel.readPaper = function (data) {
            var url = "/Student/StuAnswerDetail?&paperId=" + data.IPaperId;
            window.open(url, "_blank");
        }
        gdViewModel.init();
        ko.applyBindings(gdViewModel);


        options.frmElement.validate({
            rules: {

            },
            messages: {

            }
        });


    });

</script>






<!--/end grid code-->
